public class Leetcode713 {
    public static void main(String[] args) {
        int i = 1;
        System.out.println(++i);
    }

    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int numsLength = nums.length;
        //最终子集个数
        int res = 0;
        int left = 0;
        int right = 0;
        //乘积
        int product = 1;
        while (right < numsLength) {
            product *= nums[right];

            //如果乘了右边太大，就收缩左边
            while (product >= k && left <= right) {
                product /= nums[left++];
            }

            //只记包含右边界的子集个数，避免重复
            res += right++ - left + 1;
        }

        return res;
    }
}

